

act_type_code=[-2 -1 1 2];
avg_act2=[];
avg_act5=[];
timepoint=3;

for timepoint=1:5
for layer_id=[2 5]
    cell_cnt=0;
    for ind=1:17%length(hom_data)
        if hom_data(ind).layer==layer_id
            for knd=1:size(hom_data(ind).raw_data(timepoint).sig_act,2)
                if hom_data(ind).raw_data(timepoint).ROItype(knd)==99
                    cell_cnt=cell_cnt+1;
                    act=(hom_data(ind).raw_data(timepoint).sig_act(:,knd))/median(hom_data(ind).raw_data(timepoint).sig_act(:,knd));
                    %act=act>2;
                    for lnd=1:4
                        if layer_id==2
                            avg_act2(lnd,cell_cnt,timepoint)=mean(act(hom_data(ind).raw_data(timepoint).act_code==act_type_code(lnd)));
                        else
                            avg_act5(lnd,cell_cnt,timepoint)=mean(act(hom_data(ind).raw_data(timepoint).act_code==act_type_code(lnd)));
                        end
                    end
                end
            end
        end
    end
end
end

figure;
plot(nanmean(avg_act2'))
hold on
plot(nanmean(avg_act5'),'r')